package com.paw.hys.sa.aop;

import java.util.Arrays;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class FallbackLogAspects {
  @Pointcut("execution(public * com.paw.hys.sa.client.fallback.impl.*.*(..))")
  public void pointCut() {
  }

  @Before("pointCut()")
  public void logStart(JoinPoint joinPoint){
    Object[] args = joinPoint.getArgs();
    String clientName = joinPoint.getSignature().getDeclaringType().getInterfaces()[0].getName();
    String method = joinPoint.getSignature().getName();
    log.error("fallback {}#{} args={}",clientName,method, JSON.toJSONString(args));
  }
}
